package com.catena.web;

import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created by hx-pc on 16-12-15.
 */
@RestController
@RequestMapping("/caic-api")
public class ServerController {

    @RequestMapping(value = "/ssoAuth/validUserInfo", method = RequestMethod.GET)
    public void addMock(String id, String tiket, Long ptime,HttpServletResponse httpServletResponse) {
        httpServletResponse.setHeader(HttpHeaders.CONTENT_TYPE, "application/json");
        try {
            System.out.println(ptime);
            if (id.equals(tiket)) {
                httpServletResponse.getOutputStream().write(("{\n" +
                        "    \"result\": 0,\n" +
                        "    \"message\": \"0\",\n" +
                        "    \"data\": {" +
                        "\"userinfo\":\"58866" +
                        "$asdasdqw\"," +
                        "\"appindex\":\"\"" +
                        "}\n" +
                        "}").getBytes());
            } else {
                httpServletResponse.getOutputStream().write(("{\n" +
                        "    \"result\": 99999,\n" +
                        "    \"message\": \"未知错误\",\n" +
                        "    \"data\": {}\n" +
                        "}").getBytes());
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }


}
